library(tidyverse)
library(here)
library(readr)
library(data.table)
rwa <- "clean_data/rwa_clean.csv" %>%
here() %>%
read_csv()
"raw_data/rwa.csv" %>%
here() %>%
read_csv() %>%
data.table()
rwa %>%
data.table()
What’s the average RWA score for each gender?
rwa %>%
group_by(gender) %>%
summarise(mean_rwa = mean(rwa))
## `summarise()` ungrouping output (override with `.groups` argument)
What’s the average RWA score for left handed people vs. right handed people.
rwa %>%
group_by(hand) %>%
summarise(mean_rwa = mean(rwa))
## `summarise()` ungrouping output (override with `.groups` argument)
What’s the average family size for each type of childhood?
rwa %>%
group_by(childhood) %>%
summarise(mean_family_size = mean(family_size))
## `summarise()` ungrouping output (override with `.groups` argument)
What’s the average time to take the test for each education level?
rwa %>%
group_by(education) %>%
summarise(mean_test_time = mean(test_time))
## `summarise()` ungrouping output (override with `.groups` argument)
Whats the average RWA score for people aged - Under 18 - 18 to 25 - 26 to 40 - 41 to 60 - Over 60
rwa %>%
mutate(
age_group = case_when(
age < 18 ~ "Under 18",
age < 26 ~ "18 to 25",
age < 41 ~ "26 to 40",
age < 61 ~ "41 to 60",
age > 60 ~ "Over 60"
)
) %>%
group_by(age_group) %>%
summarise(
mean_rwa = mean(rwa)
)
## `summarise()` ungrouping output (override with `.groups` argument)